package com.sxkf.template.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxkf.core.api.vo.R;
import com.sxkf.template.entity.UserBank;
import com.sxkf.template.service.UserBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-12-03 20:29:51
 */
@Api(tags = "用户银行卡")
@RestController
@RequestMapping("/userBank")
public class UserBankController {
    @Resource
    private UserBankService userBankService;

    @ApiOperation("查询用户银行卡")
    @GetMapping("/list")
    public R<List<UserBank>> list(@RequestParam String userId){
        return R.success(userBankService.list(new LambdaQueryWrapper<UserBank>().eq(UserBank::getUserId,userId)));
    }

    @ApiOperation("新增银行卡")
    @PostMapping("/add")
    public R<?> add(@RequestBody UserBank userBank){
        userBankService.save(userBank);
        return R.success();
    }

    @ApiOperation("删除银行卡")
    @PostMapping("/delete")
    public R<?> delete(@RequestParam Integer id){
        userBankService.removeById(id);
        return R.success();
    }

    @ApiOperation("修改银行卡")
    @PostMapping("/update")
    public R<?> update(@RequestBody UserBank userBank){
        userBankService.updateById(userBank);
        return R.success();
    }
}
